//
//  Transition.swift
//  NaiCha
//
//  Created by 唐安坤 on 2024/9/6.
//

import SwiftUI

struct Transition_1: View {
    @State var isShow = true
    var body: some View {
        VStack{
            RoundedRectangle(cornerSize: CGSize(width: 20, height: 20)).foregroundColor(.orange).frame(width: 300, height: 150, alignment: .center).overlay {
                Text("嗨！欢迎学习").foregroundColor(.white).font(.system(size: 30,weight: .bold))
            }
            if isShow {
                RoundedRectangle(cornerSize: CGSize(width: 20, height: 20)).foregroundColor(.blue).frame(width: 300, height: 150, alignment: .center).overlay {
                    Text("SwiftUI课程").foregroundColor(.white).font(.system(size: 30,weight: .bold))
                }.transition(.asymmetric(insertion: .scale.combined(with: .offset(x: 0, y: 150)), removal: .opacity.combined(with: .offset(x: 0, y: -150))))
            }
            
        }.onTapGesture {
            withAnimation {
                isShow = !isShow
            }
        }
        
    }
}

#Preview {
    Transition_1()
}
